home *** CD-ROM | disk | FTP | other *** search
/ PC go! 2008 April / PCgo 2008-04 (DVD).iso / interface / contents / demoversionen_3846 / 13664 / files / Data1.cab / paldlg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-11-20  |  2.8 KB  |  111 lines

  1. /******************************************************************/
  2. /*                                                                */
  3. /*                      TurboCAD for Windows                      */
  4. /*                   Copyright (c) 1993 - 2001                    */
  5. /*             International Microcomputer Software, Inc.         */
  6. /*                            (IMSI)                              */
  7. /*                      All rights reserved.                      */
  8. /*                                                                */
  9. /******************************************************************/
  10.  
  11. // PalDlg.cpp : implementation file
  12. //
  13.  
  14. #include "stdafx.h"
  15. #include "CustomPalette.h"
  16. #include "PalDlg.h"
  17.  
  18. #ifdef _DEBUG
  19. #define new DEBUG_NEW
  20. #undef THIS_FILE
  21. static char THIS_FILE[] = __FILE__;
  22. #endif
  23.  
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CPalDlg dialog
  26.  
  27.  
  28. CPalDlg::CPalDlg(CWnd* pParent /*=NULL*/)
  29.     : CDialog(CPalDlg::IDD, pParent)
  30. {
  31.     //{{AFX_DATA_INIT(CPalDlg)
  32.         // NOTE: the ClassWizard will add member initialization here
  33.     //}}AFX_DATA_INIT
  34. }
  35.  
  36. IMPLEMENT_DYNAMIC(CPalDlg, CDialog)
  37.  
  38. void CPalDlg::DoDataExchange(CDataExchange* pDX)
  39. {
  40.     CDialog::DoDataExchange(pDX);
  41.     //{{AFX_DATA_MAP(CPalDlg)
  42.         // NOTE: the ClassWizard will add DDX and DDV calls here
  43.     //}}AFX_DATA_MAP
  44. }
  45.  
  46.  
  47. BEGIN_MESSAGE_MAP(CPalDlg, CDialog)
  48.     //{{AFX_MSG_MAP(CPalDlg)
  49.     ON_BN_CLICKED(IDC_TEST, OnTest)
  50.     //}}AFX_MSG_MAP
  51. END_MESSAGE_MAP()
  52.  
  53. /////////////////////////////////////////////////////////////////////////////
  54. // CPalDlg message handlers
  55. /*
  56. IApplication* GetTcApp()
  57. {
  58.     IApplication *pIApplication = NULL;
  59.  
  60.     BOOL bCreateInstance = TRUE;
  61.     IUnknown* pUnk = NULL;
  62.     HRESULT hRes = ::GetActiveObject(CLSID_Application, NULL, &pUnk);
  63.     if (pUnk == NULL)
  64.         return NULL;
  65.  
  66.     hRes = pUnk->QueryInterface(IID_IApplication, (void**)&pIApplication);
  67.     pUnk->Release();
  68.     if (FAILED(hRes))
  69.         return NULL;
  70.  
  71.     return pIApplication;
  72. }
  73. */
  74. IApplication* GetTcApp()
  75. {
  76.     IApplication *pIApplication = NULL;
  77.     HRESULT hRes = CoCreateInstance(CLSID_XApplication, NULL, CLSCTX_INPROC_SERVER, IID_IApplication, (void**)&pIApplication);
  78.     if (FAILED(hRes))
  79.         return NULL;
  80.     
  81.     return pIApplication;
  82.  
  83. }
  84.  
  85. void CPalDlg::OnTest() 
  86. {
  87.     HRESULT hRes = E_FAIL;
  88.     Drawings* pDrs = NULL;
  89.     long lDrawingsCount = 0;
  90.     CString strTmp;
  91.     strTmp = "There are  drawings loaded";
  92.  
  93.     IApplication* pIApp = GetTcApp();
  94.     if(pIApp !=NULL)
  95.     {
  96.         hRes = pIApp->get_Drawings(&pDrs);
  97.         if(SUCCEEDED(hRes))
  98.         {
  99.             hRes = pDrs->get_Count(&lDrawingsCount);
  100.         
  101.         }
  102.     }
  103.     char v[10];
  104.     memset(v, 0, 10);
  105.     _ltoa(lDrawingsCount,v, 10);
  106.     strTmp.Insert (10,v);
  107.     MessageBox(strTmp, "Custom docking palette");
  108.     RELEASE(pDrs);
  109.     RELEASE(pIApp);
  110. }
  111.